<?xml version = '1.0' encoding = 'UTF-8'?>
<HBRRepo><variables><variable name="PeriodsVar" type="members" usage="const" id="1" product="Planning"><property name="application">SalesPln</property><property name="plantype">OEP_GSP</property><property name="dimension">Period</property><property name="dimensionInputMode">name</property><property name="display_label">Period</property><property name="prompt_text">ID_PRMTEXT_GSP_PERIODS</property><property name="scope">87654321</property><property name="seeded">true</property><value>&amp;OEP_CurMnth</value></variable><variable name="YearsVar" type="members" usage="const" id="2" product="Planning"><property name="application">SalesPln</property><property name="plantype">OEP_GSP</property><property name="dimension">Years</property><property name="display_label">Years</property><property name="prompt_text">ID_PRMTEXT_GSP_YEARS</property><property name="scope">87654321</property><property name="seeded">true</property><value>"No Year"</value></variable></variables><rulesets/><rules><rule id="1" name="OGS_PrepareForecast" product="Planning"><property name="application">SalesPln</property><property name="plantype">OEP_GSP</property><property name="seeded">true</property><variable_references><variable_reference name="PeriodsVar" id="1"><property name="application">SalesPln</property><property name="hasvalue">true</property><property name="hidden">false</property><property name="plantype">OEP_GSP</property><property name="rule_name">OGS_PrepareForecast</property><property name="seq">1</property><property name="type">4</property><property name="useAsOverrideValue">false</property><property name="value">&amp;OEP_CurMnth</property></variable_reference><variable_reference name="YearsVar" id="2"><property name="application">SalesPln</property><property name="hasvalue">true</property><property name="hidden">false</property><property name="plantype">OEP_GSP</property><property name="rule_name">OGS_PrepareForecast</property><property name="seq">2</property><property name="type">4</property><property name="useAsOverrideValue">false</property><property name="value">&amp;OEP_CurYr</property></variable_reference></variable_references><script type="groovy">/* RTPS:  {PeriodsVar} {YearsVar} */
def calcScript = new StringBuilder()

List&lt;String> CustomDimensions=[];
List&lt;String> CustomRelDimensions=[];
List&lt;String>  periods=rtps.PeriodsVar.members.name;
List&lt;String>  years=rtps.YearsVar.members.name;
String EntityDim="";
int iCnt;
boolean isCurrencyApp= false

Application app=operation.getApplication();
UserVariable uservar=app.getUserVariable("OGS_ASF Scenario");

def Scenario=uservar.getValue();

Cube gsp=app.getCube("OEP_GSP"); 
List&lt;Dimension> dimlist=app.getDimensions(gsp);

for (Dimension dim : dimlist) {
	DimensionType dType=dim.getType();
	if ((dType==DimensionType.CUSTOM &amp;&amp; dim.name != "Plan Element")) {
		CustomRelDimensions.add('''@Relative("OEP_Total '''+dim.getName()+'''",0)''');
		CustomDimensions.add(dim.getName());
	}
	if (dType==DimensionType.CURRENCY) {
		isCurrencyApp=true;
	}
	if (dType==DimensionType.ENTITY) { 
		CustomRelDimensions.add('''@Relative("OEP_Total '''+dim.getName()+'''",0)''');
		EntityDim=dim.getName();
	}
}    

/*Calc Script */				
calcScript.append('''SET UPDATECALC OFF;\n''');

/*Main fix*/          
calcScript.append('''FIX("OGS_Base Forecast",&amp;OEP_CurYr,"OEP_Working Bottom Up"''');
if (periods.size()>0) {
	calcScript.append(''','''+periods.join(''',''')+'''\n''');
}

if (isCurrencyApp==true) {
	calcScript.append(''',@levmbrs(Currency,0)''');		
}
calcScript.append(''')\n''');
calcScript.append('''	FIX(''')
calcScript.append(CustomRelDimensions.join(''','''));
calcScript.append(''')\n''');

/*Copies data from Actual for Forecast*/

calcScript&lt;&lt;''' FIX(@Relative("Measures",0))''';
calcScript&lt;&lt;''' datacopy "OEP_Actual" to "'''+Scenario+'''";''';
calcScript&lt;&lt; '''ENDFIX'''
calcScript&lt;&lt;''' Fix("'''+Scenario+'''")
calc dim("Measures");
ENDFIX
ENDFIX
ENDFIX'''  
println(calcScript.toString())
return calcScript.toString()
</script></rule></rules><components/><deployobjects><deployobject product="2" application="salespln" plantype="oep_gsp" obj_id="1" obj_type="1" name="OGS_PREPAREFORECAST"/></deployobjects></HBRRepo>